<!DOCTYPE HTML>
<html  xmlns:th="http://www.thymeleaf.org">
<head th:include="_meta :: header">
    <title>编辑管理员 - 管理员管理 </title>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" id="form-admin-add" action="#" th:action="@{#}" th:object="${user}">
            <input type="hidden" name="save" value="true"/>
            <input type="hidden" name="id" value="" th:field="*{id}"/>

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>姓名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="account" name="username"   required="" lay-verify="required"
                           autocomplete="off" class="layui-input" th:field="*{account}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>账号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="username" name="username"  readonly="readonly" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" th:field="*{username}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>性别
                </label>
                <div class="layui-input-inline">
                    <input type="radio" id="sex-1" name="sexType" value="1" th:field="*{sexType}" title="男"  checked="checked">
                    <input type="radio"  id="sex-0" name="sexType" value="0" th:field="*{sexType}" title="女">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="password" name="password"
                           autocomplete="new-password" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="password2" name="password2"
                           autocomplete="new-password" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    手机
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="tel" name="tel"  th:field="*{tel}"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    邮箱
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="email" name="email" r th:field="*{email}"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                <button  class="layui-btn" id="subbtn" type="submit">
                    保存
                </button>
            </div>
        </form>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->
<div th:replace="_footer :: footerjs"></div>
<div th:replace="_ueditor :: ueditor"></div>
<!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->

<script type="text/javascript">
    $(function(){
        layui.use(['form', 'layer'],function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
        });

        $("#form-admin-add").validate({
            rules:{
                username:{
                    required:true,
                    minlength:4,
                    maxlength:16
                },
                sexType:{
                    required:true,
                },
                password:{
                    required:true,
                },
                password2:{
                    required:true,
                    equalTo: "#password"
                },
            },
            onkeyup:false,
            success:"valid",
            submitHandler:function(form){
                $(form).ajaxSubmit({
                    type: 'post',
                    url: "/usecase/usecase/editToShow" ,
                    success: function(data){
                        console.log(data);
                        if(data.code == "1"){
                            selfmsg('编辑成功!', 1,function(){
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.location.reload();
                                parent.layer.close(index);
                            });
                        }else{
                            layer.msg('编辑失败!',{icon:0,time:1000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg('error!',{icon:0,time:1000});
                    }
                });
            }
        });
    });
</script>
</body>
</html>